<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('开户积分')" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="formId">
				<div class="select-list">
					<ul>
						<li>
							<label>预约编号：</label>
							<input type="text" name="reNumber"/>
						</li>
						<li>
							<label>企业名称：</label>
							<input type="text" name="companyName"/>
						</li>
						<li>
							<label>预约日期：</label>
							<input type="text" class="time-input" placeholder="请选择预约日期" name="reDate"/>
						</li>
						<li>
							<label>接洽日期：</label>
							<input type="text" class="time-input" placeholder="请选择接洽日期" name="acceptDate"/>
						</li>
						<li>
							<label>账户性质：</label>
							<select name="accountType" th:with="type=${@dict.getType('account_type')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
						</li>
						<li>
							<label>账号：</label>
							<input type="text" name="accountNo"/>
						</li>

						<li>
							<label>联系电话：</label>
							<input type="text" name="contactsTel"/>
						</li>
						<li>
							<label>联系人：</label>
							<input type="text" name="contactsName"/>
						</li>
						<li>
							<label>预约银行：</label>
							<input type="text" name="orgName"/>
						</li>

						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>
		<div class="btn-group-sm" id="toolbar" role="group">
			<a class="btn btn-warning" onclick="cash()" shiro:hasPermission="system:account:cash">
				<i class="fa fa-plus"></i> 我要提现
			</a>

		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
	var editFlag = [[${@permission.hasPermi('system:info:edit')}]];
	var removeFlag = [[${@permission.hasPermi('system:info:remove')}]];
	var accountTypeDatas = [[${@dict.getType('account_type')}]];
	var accountStateDatas = [[${@dict.getType('account_state')}]];
	var accountCheckDatas = [[${@dict.getType('account_check')}]];
	var cashDatas = [[${@dict.getType('cash_type')}]];
	var prefix = ctx + "system/info";

	$(function() {
		var options = {
			url: prefix + "/openScoringList",
			showFooter: true,
			showToggle: false,
			showColumns: false,
			modalName: "开户积分",
			footerStyle: footerStyle,
			columns: [{
				checkbox: true
			},
				{
					field: 'id',
					title: 'id',
					visible: false
				},
				{
					field: 'reNumber',
					title: '预约编号'
				},
				{
					field: 'companyName',
					title: '企业名称'
				},
				{
					field: 'reDate',
					title: '预约日期'
				},
				{
					field: 'acceptDate',
					title: '接洽日期'
				},
				{
					field: 'accountType',
					title: '账户性质',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(accountTypeDatas, value);
					}
				},
				{
					field: 'accountNo',
					title: '账号'
				},
				{
					field: 'accountState',
					title: '账户状态',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(accountStateDatas, value);
					}
				},
				{
					field: 'contactsTel',
					title: '联系人电话'
				},
				{
					field: 'contactsName',
					title: '联系人姓名'
				},
				{
					field: 'orgId',
					title: '预约银行机构ID',
					visible: false
				},
				{
					field: 'orgName',
					title: '预约银行机'
				},
				{
					field : 'bonus',
					title : '积分',
					footerFormatter:function (value) {
						var sumBalance = 0;
						for (var i in value) {
							sumBalance += parseFloat(value[i].bonus);
						}
						return "总金额：" + sumBalance;
					}
				},
				{
					field: 'cashState',
					title: '提现标识',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(cashDatas, value);
					}
				},
				// {
				// 	field: 'accountCheck',
				// 	title: '审核状态',
				// 	formatter: function(value, row, index) {
				// 		return $.table.selectDictLabel(accountCheckDatas, value);
				// 	}
				// },


				]
		};
		$.table.init(options);
	});

	function footerStyle(column) {
		return {
//         	    userBalance: {
//         	        classes: 'class'
//         	    },
			bonus: {
				css: { color: 'red', 'font-weight': 'normal' }
			}
		}[column.field]
	}

	function cash() {
		table.set();
		var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
		if (rows.length == 0) {
			$.modal.alertWarning("请至少选择一条记录");
			return;
		}
		$.modal.confirm("确认要提现选中的" + rows.length + "条数据吗?", function() {
			var url = ctx + "system/info/cash";
			var data = { "ids": rows.join() };

			$.operate.submit(url, "post", "json", data);
		});
	}
</script>
</body>
</html>